package com.ruoyi.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.common.annotation.Anonymous;
import com.ruoyi.domain.Keshi1;
import com.ruoyi.service.IKeshi1Service;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;

import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 科室1Controller
 * 
 * @author ya
 * @date 2025-04-23
 */
@RestController
@RequestMapping("/keshi1/keshi1")
public class Keshi1Controller extends BaseController
{
    @Autowired
    private IKeshi1Service keshi1Service;

    /**
     * 查询科室1列表
     */
    @Anonymous
    @GetMapping("/list")
    public TableDataInfo list(Keshi1 keshi1)
    {
        //startPage();
        List<Keshi1> list = keshi1Service.selectKeshi1List(keshi1);
        return getDataTable(list);
    }

    /**
     * 查询科室1列表
     */
    @Anonymous
    @GetMapping("/list/ruoyi")
    public TableDataInfo list1(Keshi1 keshi1)
    {
        startPage();
        List<Keshi1> list = keshi1Service.selectKeshi1List(keshi1);
        return getDataTable(list);
    }

    /**
     * 导出科室1列表
     */
    @Anonymous
    @Log(title = "科室1", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Keshi1 keshi1)
    {
        List<Keshi1> list = keshi1Service.selectKeshi1List(keshi1);
        ExcelUtil<Keshi1> util = new ExcelUtil<Keshi1>(Keshi1.class);
        util.exportExcel(response, list, "科室1数据");
    }

    /**
     * 获取科室1详细信息
     */
    @Anonymous
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(keshi1Service.selectKeshi1ById(id));
    }

    /**
     * 新增科室1
     */
    @Anonymous
    @Log(title = "科室1", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Keshi1 keshi1)
    {
        return toAjax(keshi1Service.insertKeshi1(keshi1));
    }

    /**
     * 修改科室1
     */
    @Anonymous
    @Log(title = "科室1", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Keshi1 keshi1)
    {
        return toAjax(keshi1Service.updateKeshi1(keshi1));
    }

    /**
     * 删除科室1
     */
    @Anonymous
    @Log(title = "科室1", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(keshi1Service.deleteKeshi1ByIds(ids));
    }
}
